package Calendar;

import java.util.Scanner;

public class day {
	
	public int D = 1,M = 1,Y = 1,Number_of_Mouth = 1,
			DoM[] = {0,31,28,31,30,31,30,31,31,30,31,30,31},
			DoW = 0,Number_of_day = 0;
	

	public int Search(week day){
		if(day.M == M && day.Y == Y)return (day.D-D+DoW)%7;
		if(day.Y == Y && day.M != M)
		{
			while(Number_of_Mouth<day.M)
			{
				Number_of_day = Number_of_day+DoM[Number_of_Mouth];
				Number_of_Mouth++;
			}
			Number_of_day = Number_of_day+day.D;
			return (Number_of_day-D+DoW)%7;
		}
		if(day.Y != Y)
		{
			if(day.Y>Y)
			{
				int Number_of_Year = day.Y - Y;
	
				Number_of_day = 365*Number_of_Year+Number_of_Year/4;
				
				if(day.M == M)
				{
					Number_of_day = Number_of_day+day.D;
					return (Number_of_day-D+DoW)%7;
				}
				else if(day.M != M)
				{
					int mcount = 1;
					while(mcount<day.M)
					{
						Number_of_day = Number_of_day+DoM[mcount];
						mcount++;
					}
					if(day.Y%4 == 0 && day.M>2 )Number_of_day = Number_of_day+1;
					Number_of_day = Number_of_day+day.D;
					return (Number_of_day-D+DoW)%7;
				}
			}
		}
		return 1;
	}

}
